/**
 * 
 */
package com.easidea.tim.entity.saleorder;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Where;
import org.springside.core.dao.extend.Undeletable;

import com.easidea.tim.entity.BaseEntity;
import com.easidea.tim.entity.customer.Customer;

/**
 * 
 * 销售订单
 * @author Harrison
 *
 */
@Entity(name="tim_salesoder_order")
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Cache(region="tim_salesoder_order", usage=CacheConcurrencyStrategy.READ_WRITE)
@Undeletable(status="deleted")
public class SaleOrder extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5392359821629088123L;
	
	public final static String order_type_sale = "0"; /* 销售订单 */
    public final static String order_type_sample = "1"; /* 剪样*/
    public final static String order_type_salereturn = "2"; /* 销售退货  */
    public final static String order_type_sample_return = "3"; /* 剪样退货 */
    
    public final static String order_staus_allow = "0";/*允许备货*/
    public final static String order_staus_complete = "1"; /* 填充 */
    public final static String order_staus_pass = "2"; /* 许可 */
    public final static String order_staus_send = "3"; /* 发货 */
    public final static String order_staus_over = "4"; /* 已发货，结束 */
    
    
	private String saleOrderNum;//订单编号
	
	private Customer customer;//客户
	
	private String responer;//责任人
	
	private String reTel;//收货电话
	
	private String reAddress;//收获地址
	
	private String rePerson;//收货人
	
	private Double piNum;//总匹数
	
	private Double meterNum;//总米数
	
	private Double moneyNum;//总价
	

	
	private String memo;//备注
	
	private Short status;//订单状态
	
	private boolean starFlag;//是否星标
	
	private String flowNo;
	
	private String orderType;//订单类型，购买，退货，剪样出单，剪样退货
	
	private List<SaleOrderItem> items;



	@Column(name="orderType", nullable=false)
	public String getOrderType() {
		return orderType;
	}

	public void setOrderType(String orderType) {
		this.orderType = orderType;
	}

	@Column(name="saleOrderNum", nullable=false)
	public String getSaleOrderNum() {
		return saleOrderNum;
	}

	public void setSaleOrderNum(String saleOrderNum) {
		this.saleOrderNum = saleOrderNum;
	}

	@Column(name="responer", nullable=false)
	public String getResponer() {
		return responer;
	}

	public void setResponer(String responer) {
		this.responer = responer;
	}

	@Column(name="reTel", nullable=false)
	public String getReTel() {
		return reTel;
	}

	public void setReTel(String reTel) {
		this.reTel = reTel;
	}

	@Column(name="reAddress", nullable=false)
	public String getReAddress() {
		return reAddress;
	}

	public void setReAddress(String reAddress) {
		this.reAddress = reAddress;
	}

	@Column(name="rePerson", nullable=false)
	public String getRePerson() {
		return rePerson;
	}

	public void setRePerson(String rePerson) {
		this.rePerson = rePerson;
	}

	@Column(name="piNum")
	public Double getPiNum() {
		return piNum;
	}

	public void setPiNum(Double piNum) {
		this.piNum = piNum;
	}
	
	
	@Column(name="flowNo")
	public String getFlowNo() {
		return flowNo;
	}

	public void setFlowNo(String flowNo) {
		this.flowNo = flowNo;
	}

	@Column(name="meterNum")
	public Double getMeterNum() {
		return meterNum;
	}

	public void setMeterNum(Double meterNum) {
		this.meterNum = meterNum;
	}

	@Column(name="moneyNum", nullable=false)
	public Double getMoneyNum() {
		return moneyNum;
	}

	public void setMoneyNum(Double moneyNum) {
		this.moneyNum = moneyNum;
	}

	@Column(name="memo")
	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}
	
	@Column(name="status", nullable=false)
	public Short getStatus() {
		return status;
	}

	public void setStatus(Short status) {
		this.status = status;
	}

	@Column(name="starFlag", nullable=false)
	public boolean getStarFlag() {
		return starFlag;
	}

	public void setStarFlag(boolean starFlag) {
		this.starFlag = starFlag;
	}

	@ManyToOne(cascade=CascadeType.MERGE)
	@JoinColumn(name="customer_id",nullable=false)
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	
	 
	@OneToMany(fetch=FetchType.LAZY,mappedBy="saleOrder")	
	@Where(clause="deleted <> 1")
	public List<SaleOrderItem> getItems() {
		return items;
	}
	public void setItems(List<SaleOrderItem> items) {
		this.items = items;
	}
}
